// const map = new Map();
const map = new WeakMap();

function expensiveComputation(obj) {
    if (!map.has(obj)) {
        map.set(obj, {value: obj.data * 2})
    }

    return map.get(obj)
}

let obj1 = {data: 10}
let obj2 = {data: 20}

console.log(expensiveComputation(obj1))
console.log(expensiveComputation(obj2))

obj1 = null

console.log(map.get(obj2))

// Object.freeze

// Bigint

// generator

// Symbol